import axios from 'axios'
// import cookie from './cookie'

const service = axios.create({
  baseURL: 'https://e-commerce.kaikeba.com/shop-api/',
  timeout: 5000
})

service.interceptors.request.use(
  (config) => {
    // 请求头处理
    // // 请求头中携带 token 信息
    // if (cookie.getCookie('token') && config.url !== 'oauth/token') {
    //   config.headers.Authorization = `Bearer ${cookie.getCookie('token')}`
    // }
    // return config
    if (config.status === 200) {
      return config
    }
    return config
  },
  (error) => Promise.reject(error)
)
service.interceptors.response.use(
  (response) => {
    const res = response

    return res
  },
  (error) => Promise.reject(error)
)

export default service
